<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<!--Bhaskar added a url rewriting to the tag immediately written below this line.-->
<chiptrack:checkLogon sourcePage="/changeOrders.do?isSample=1"/>

<%@ page import="java.util.ArrayList,
                 com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.users.Functionality,
                 com.scalar.chiptrack.users.User,
                 com.scalar.chiptrack.sales.Orders"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</script>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<script  language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<SCRIPT language="JavaScript">
     window.onload = init;

    function init()
    {
        qs_1 = new QuickSearch(document.ordersForm['salesOrderNo'], document.ordersForm.qs1, false);
        qs_2 = new QuickSearch(document.ordersForm['customerPO'], document.ordersForm.qs2, false);
        qs_3 = new QuickSearch(document.ordersForm['manufacturingPartNo'], document.ordersForm.qs3, false);
        qs_4 = new QuickSearch(document.ordersForm['customerId'], document.ordersForm.qs4, false);
    }
    // Modified popup window names acc to usage by veeru on 6th April 2004
    function searchOrderList(theForm)
    {
        if(!isInteger(theForm.year.value)) {
            errors = "<li> Please enter a valid integer";
            var pa=document.getElementById("errors1");
            pa.innerHTML = errors;
            theForm.year.select();
            return false;
        }

        theForm.action.value = "SearchOrder";
        //theForm.submit();
        return true;
    }

    function GetAllProducts()
    {
        newWindow = window.open('loadProducts.do','productsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=500,height=600,left=300,top=30,resizable=no');
  	//newWindow.moveTo(300,30);
  	newWindow.focus();
    }

    function assignProduct(passedValue)
    {
	document.ordersForm.manufacturingPartNo.value = passedValue;
	window.focus();
    }

    // SharatH on July 31, 2003
    function showErrorReportPage()
    {
        newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
        newWindow.focus();
    }
function reset()
{
    document.ordersForm.reset();
    qs_1.resetQuickSearchCntrl();
    qs_2.resetQuickSearchCntrl();
    qs_3.resetQuickSearchCntrl();
    qs_4.resetQuickSearchCntrl();
}
</SCRIPT>


<SCRIPT language='JavaScript'>

    function openSalesOrder()
    {
       var isSample = document.ordersForm.isSample.value;
       // newWindow =
	   window.open('order.do?action=printOrder&revisedDate=false&salesOrderId=<%=(String)request.getAttribute("salesOrderId")%>&isSample='+isSample,'salesOrderPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=600,height=600,left=100,top=50,resizable=yes');
  	//newWindow.moveTo(100,50);
  	//newWindow.focus();
    }


</SCRIPT>



<!-- Top Header Start-->

    <%
        String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
    %>
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>

<!-- Top Header End-->
  
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->

<%
 String heading = ""; 
 String isSample = "1";
%>
<% if((request.getParameter("isSample") != null) && (request.getParameter("isSample").equals("0"))) { 
         heading = "Sample Orders"; isSample="0";
%>
	    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/sample_order_menu.jsp" %>
        </logic:equal>
        <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/ext_sample_order_menu.jsp" %>
        </logic:notEqual>
<% } else { 
     heading = "Sales Orders";isSample="1";
%>
        <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/sales_order_menu.jsp" %>
        </logic:equal>
        <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/ext_sales_order_menu.jsp" %>
        </logic:notEqual>        
<% } %>



<!-- end of the side navigations -->
</TD>

<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->


<html:form name="ordersForm" onsubmit="return searchOrderList(document.ordersForm);" method="post" action="/changeOrders" type="com.scalar.chiptrack.sales.forms.OrdersForm">

<center><span class="NArialW">Search for <%=heading%> to modify </span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>

<div align=right>
<table border="0" width="90%">
 <tr><td>
    <chiptrack:info styleClass="NArialL" />
    <chiptrack:errors styleClass="NArialL" />
    <chiptrack:messages type="info" styleClass="NArialL" />
 </td></tr>
</table>
</div>

<table border="0" width="100%" align=left>
 <tr><td>
 <table border="0" width="100%" align=left>
    <tr><td colspan='6' align="left" class='NArialL'><FONT id="errors1" color='FF0000'></FONT></TD></TR>
    <tr><td colspan='6'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr>
      <td width="10%">&nbsp;</td>
      <td width="25%" align="right" class="NArialL">Quick Search:</td>
      <td width="25%">
        <input type="text" name="qs3" class="txfield" size='33' onkeyup='quickSearch(qs_3);'/>
      </td>
      <td width="5%">&nbsp;</td>
      <td width="20%" align="right"><font class="NArialL">Quick Search:</font></td>
      <td width="20%">
            <input type="text" name="qs4" class="txfield" size='33' onkeyup='quickSearch(qs_4);'/>
      </td>

    </tr>
    <tr>
      <td width="10%">&nbsp;</td>
      <td width="25%" align="right">
		  <font class="NArialL">Product Name:<br><bean:message key="label.mfgPartNumber"/>)</font>
	  </td>
      <td width="20%"><font class="NArialL">
           <html:select name="ordersForm" property="manufacturingPartNo" styleClass="txfield">
                <html:options collection="productList" property="value" labelProperty="label"/>
           </html:select>
      </td>
      <td width="5%">&nbsp;</td>
      <td width="20%" align="right" nowrap><font class="NArialL">Customer Name:</font></td>
      <td width="20%"><font class="NArialL">
        <html:select name="ordersForm" property="customerId" styleClass="txfield">
            <html:options collection="customerList" property="value" labelProperty="label"/>
        </html:select>
      </td>

    </tr>
     <TR>
         <td width="10%">&nbsp;</td>
         <TD width="25%" class=NArialL align="right" valign="top">Quick Search:</TD>
         <TD width="20%" class=NArialL valign="top">
             <input type="text" name="qs1" class="txfield" size='20' onkeyup='quickSearch(qs_1);'/>
         </TD>
         <TD width="5%">&nbsp;</TD>
         <TD width="20%"  valign="top" align="right"><font class="NArialL">Quick Search:</font></TD>
         <td width="20%"  valign="top">
             <input type="text" name="qs2" class="txfield" size='20' onkeyup='quickSearch(qs_2);'/>
         </td>
    </TR>
    <tr>
      <td width="10%">&nbsp;</td>
      <td width="20%" align="right"><font class="NArialL">Sales Order #:</font></td>
      <td width="20%"><font class="NArialL">
          <html:select name="ordersForm" property="salesOrderNo" styleClass="txfield">
            <html:options collection="salesOrdersList" property="value" labelProperty="label"/>
        </html:select>
      <%--<html:text name="ordersForm" property="salesOrderId" size="20" styleClass="txfield" />--%>
     </td>
      <td width="5%">&nbsp;</td>
      <td width="20%" align="right"><font class="NArialL">Customer PO# </font></td>
	  <td width="20%"><font class="NArialL"><%--<html:text name="ordersForm" property="customerPO" size="20" styleClass="txfield" />--%>
          <html:select name="ordersForm" property="customerPO" styleClass="txfield">
            <html:options collection="posList" property="value" labelProperty="label"/>
        </html:select>
      </td>
  	  <%--<td width="15%">&nbsp;</td>--%>
	</tr>
    <tr>
        <td width="10%">&nbsp;</td>
        <td width="25%" align="right"><font class="NArialL"><bean:message key="label.sales.endCustomer"/>:</font></td>
        <td width="20%"><font class="NArialL">
            <html:select name="ordersForm" property="endCustomer" styleClass="txfield">
                <html:option value="0">All <bean:message key="label.sales.endCustomer"/>s</html:option>
                <html:options collection="endCustomerList" property="value" labelProperty="label"/>
            </html:select></font></td>
              <td width="5%">&nbsp;</td>
            <td width="20%" align="right"><font class="NArialL"><bean:message key="label.sales.endUser"/>:</font></td>
          <td width="20%"><font class="NArialL">
            <html:select name="ordersForm" property="endUser" styleClass="txfield">
              <html:option value="0">All <bean:message key="label.sales.endUser"/>s</html:option>
                    <html:options collection="endUserList" property="value" labelProperty="label"/>
            </html:select>
             </td>
        <%--<td width="15%">&nbsp;</td>--%>
    </tr>
	<tr>
        <td width="10%">&nbsp;</td>
		<td width="25%" align="right"><font class="NArialL">Year:</font></td>
		<td width="20%">
		<html:select name="ordersForm" property="year" styleClass="txfield">
			<html:option value="">--All--</html:option>
			<html:options collection="years" property="value" labelProperty="label" />
		</html:select>
		</td>
		<td colspan='3' width="45%">&nbsp;</td>
	</tr>
    <tr><td colspan='6'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>
    <tr>
      <td width="10%">&nbsp;</td>  
      <td colspan='5' width="10%">
      <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
          <logic:equal name="viewShippedOrders" value="YES">
			<input type="checkbox" name="viewShippedOrders" CHECKED >
          </logic:equal>
          <logic:equal name="viewShippedOrders" value="NO">
			<input type="checkbox" name="viewShippedOrders" >
          </logic:equal>
          <font class="NArialL">Do you want to see Shipped Orders.</font>
      </logic:equal>
      </td>
    </tr>
    <tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>
    <tr>
      <td colspan=6 align=center>
         <input type=image border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click here to Search for  Sales Order List';return true" onmouseout="window.status='';return true" title="Click here to Search for Sales Order List">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <a href="javascript:reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"  onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset" ></a></td>
    </tr>
   </table>
   </td></tr>
   <tr><td><img height=5 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr>
   <tr><td>
   <logic:equal name="showList" value="TRUE">
   <table border="0" width="100%" align=right>
	<tr>
	  <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Sales Order #</font></td>
	  <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Customer Name</font></td>
      <td align="center" bgcolor='#993333' class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.endCustomer"/></font></td>
      <td align="center" bgcolor='#993333' class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.endUser"/></font></td>
	  <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Booking Date</font></td>
	  <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Status</font></td>
	  <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Actions</font></td>
	</tr>
        <% int bgcount = 0;%>
        <% ArrayList orderList = ( ArrayList ) request.getAttribute( "ordersList" ); %>
	<logic:iterate id="Orders" name="ordersList">
        <% bgcount = bgcount + 1; %>
	<tr>
	  <td width="10%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><bean:write name="Orders" property="salesOrderNo"  /></font></td>
	  <td width="15%" align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><bean:write name="Orders" property="customerName" /></font></td>
	  <td width="15%" align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><bean:write name="Orders" property="endCustomerName" /></font></td>
	  <td width="15%" align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><bean:write name="Orders" property="endUserName" /></font></td>
	  <td width="15%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><bean:write name="Orders" property="bookingDate" /></font></td>
          <td width="15%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><bean:write name="Orders" property="status" /></font></td>
	  <td width="15%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="leftsection">
                <%
                    Orders orders = ( Orders ) orderList.get( bgcount -1 );
                    int salesOrderId = orders.getSalesOrderId();
                %>
                <% if( ( request.getParameter("isSample") != null ) && ( request.getParameter( "isSample" ).equals( "0" ) ) ) { %>
                    <chiptrack:restrictedLink functionality='<%=Functionality.SAMPLE_CHANGE_ORDER%>' action='<%=User.USER_ACTION_VIEW%>' styleClass="leftsection" href='<%=chipTracContext + "/changeOrder.do?salesOrderId=" + salesOrderId + "&isSample=" + isSample%>' onmouseover="window.status='Click to Modify sales order';return true" onmouseout="window.status='';return true">Modify</chiptrack:restrictedLink>
                <% } else { %>
                    <chiptrack:restrictedLink functionality='<%=Functionality.SALES_CHANGE_ORDER%>' action='<%=User.USER_ACTION_VIEW%>' styleClass="leftsection" href='<%=chipTracContext + "/changeOrder.do?salesOrderId=" + salesOrderId + "&isSample=" + isSample%>' onmouseover="window.status='Click to Modify sales order';return true" onmouseout="window.status='';return true">Modify</chiptrack:restrictedLink>
                <% } %>

            </font></td>

<!--
<A HREF='<%=chipTracContext + "/changeOrder.do?salesOrderId=" + salesOrderId + "&isSample=" + isSample%>'
<bean:write name="Orders" property="salesOrderId"/>&isSample=<%=isSample%>" > Modify </A>
-->


	</tr>
        </logic:iterate>
    </table>
    </logic:equal>
    </td></tr>
</table>

<input type="hidden" name="action" value="">
<input type="hidden" name="isSample" value="<%=request.getParameter("isSample")%>">
</html:form>


<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->

<%@ include file="/jsp/includes/footer.jsp" %>

<!-- footer end here -->
</BODY>
</HTML>
